﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;
using DBUlitity;
using System.Data;

namespace BLL
{
    public class CustomerBLL
    {
        /// <summary>
        /// 新增客户信息
        /// </summary>
        /// <param name="CustomDiYu"></param>
        /// <param name="CustomName"></param>
        /// <param name="CustomChejian"></param>
        /// <param name="provience"></param>
        /// <param name="city"></param>
        /// <param name="area"></param>
        /// <param name="CustomDetailAddress"></param>
        /// <param name="CustomLng"></param>
        /// <param name="CustomLat"></param>
        /// <param name="CustomImg"></param>
        /// <param name="customerstate"></param>
        /// <param name="InstallDate"></param>
        /// <param name="installstate"></param>
        /// <param name="Reamrk"></param>
        /// <returns></returns>
        public static string addCustomInfo(string CustomDiYu, string CustomName, string CustomChejian, string provience, string city, string area, string CustomDetailAddress, string CustomLng, string CustomLat,string CustomImg,string customerstate, string InstallDate,string installstate, string Reamrk)
        {
            string jsonStr =CustomerDAL.addCustomInfo(CustomDiYu, CustomName, CustomChejian, provience, city, area, CustomDetailAddress, CustomLng, CustomLat,CustomImg,customerstate, InstallDate,installstate, Reamrk) ;
            return jsonStr;
        }

        /// <summary>
        /// 保存编辑客户信息
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <param name="CustomDiYu"></param>
        /// <param name="CustomName"></param>
        /// <param name="CustomChejian"></param>
        /// <param name="provience"></param>
        /// <param name="city"></param>
        /// <param name="area"></param>
        /// <param name="CustomDetailAddress"></param>
        /// <param name="CustomLng"></param>
        /// <param name="CustomLat"></param>
        /// <param name="CustomImg"></param>
        /// <param name="customerstate"></param>
        /// <param name="InstallDate"></param>
        /// <param name="installstate"></param>
        /// <param name="Reamrk"></param>
        /// <returns></returns>
        public static string editCustomInfo(string CustomerID, string CustomDiYu, string CustomName, string CustomChejian, string provience, string city, string area, string CustomDetailAddress, string CustomLng, string CustomLat, string CustomImg, string customerstate, string InstallDate, string installstate, string Reamrk)
        {
            string jsonStr = CustomerDAL.editCustomInfo(CustomerID,CustomDiYu, CustomName, CustomChejian, provience, city, area, CustomDetailAddress, CustomLng, CustomLat, CustomImg, customerstate, InstallDate, installstate, Reamrk);
            return jsonStr;
        }
        /// <summary>
        /// 客户信息列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="keyvalue"></param>
        /// <returns></returns>
        public static DataTable GetCustomerInfo(string sidx, string sord, string keyvalue)
        {
            DataTable dt = new DataTable();
            dt = CustomerDAL.GetCustomerInfo(sidx, sord, keyvalue); 
            return dt;
        }
        /// <summary>
        /// 客户所购设备列表
        /// </summary>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <param name="CustomerID"></param>
        /// <param name="keyvalue"></param>
        /// <returns></returns>
        public static DataTable GetCustomerEquInfo(string sidx, string sord, string CustomerID, string keyvalue)
        {
            DataTable dt = new DataTable();
            dt = CustomerDAL.GetCustomerEquInfo(sidx, sord,CustomerID, keyvalue);
            return dt;
        }

        /// <summary>
        ///  根据ID查找客户厂名   车间
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static string getCustomNameByID(string ID)
        {
            string jsonStr = "[]";
            List<CustomerNameChejian> customerList = CustomerDAL.getCustomNameByID(ID);
            jsonStr = JSONTools.ScriptSerialize<List<CustomerNameChejian>>(customerList);
            return jsonStr;
        }
        /// <summary>
        /// 根据ID查找客户全部信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static string getCustomInfoByID(string ID)
        {
            string jsonStr = "[]";
            List<CustomerInfo> customerList = CustomerDAL.getCustomInfoByID(ID);
            jsonStr = JSONTools.ScriptSerialize<List<CustomerInfo>>(customerList);
            return jsonStr;
        }


        public static string saveCustomerEquKaoHaoInfo(string CustomerID, string EquType, string totalcount, List<string> EquNo, List<string> TaiHao)
        {
            string jsonStr = CustomerDAL.saveCustomerEquKaoHaoInfo(CustomerID,EquType,totalcount,EquNo,TaiHao); 
            return jsonStr;
        }

        public static string deleteCustomerInfo(string CustomerID)
        {
            int t = CustomerDAL.deleteCustomerInfo(CustomerID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }
        public static string deleteCustomerEquInfo(string CustomerEquID)
        {
            int t = CustomerDAL.deleteCustomerEquInfo(CustomerEquID);
            string jsonStr = string.Empty;
            if (t > 0)
            {
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }

        /// <summary>
        /// 设置客户设备投入使用时间
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <param name="UseDate"></param>
        /// <returns></returns>
        public static string setCustomerUseDate(string CustomerID, string UseDate)
        {
            string jsonStr = CustomerDAL.setCustomerUseDate(CustomerID, UseDate);
            return jsonStr;
        }

        /// <summary>
        /// 监听客户需要维护的设备信息
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        public static string getCustomerMaintenanceInfo(string CustomerID)
        {
            string jsonStr = "[]";
            List<EquInfo> customerList = CustomerDAL.getCustomerMaintenanceInfo(CustomerID);
            jsonStr = JSONTools.ScriptSerialize<List<EquInfo>>(customerList);
            return jsonStr;
        }

        /// <summary>
        /// 监听客户发布的问题
        /// </summary>
        /// <returns></returns>
        public static string getCustomerProblem(string Userno)
        {
            return CustomerDAL.getCustomerProblem(Userno);
        }

    }
}
